package com.cari.oa.dao;


import java.util.List;

import org.hibernate.Query;
import org.springframework.stereotype.Repository;
import com.cari.oa.domain.ReqUserRefEntity;

@Repository
public class ReqUserRefDao extends BaseDao<ReqUserRefEntity> {

	/**
	* Title: getByEnname
	* Description:根据英文名获取关联的需求类型
	* @author    hjx 
	* @date       2013-3-18 
	* @param enname
	* @return
	*/
	public ReqUserRefEntity getByEnname(String enname) {
		 Query query = getSession().createQuery("from ReqUserRefEntity where enname = :enname");
         query.setString("enname", enname);
         @SuppressWarnings("unchecked")
		 List<ReqUserRefEntity> list = query.list();
         if(list.size()>0)
		     return  list.get(0);
         else
        	 return new ReqUserRefEntity();
	}

	public ReqUserRefEntity getByReqType(String typeId) {
		 Query query = getSession().createQuery("from ReqUserRefEntity where typeId = :typeId");
         query.setString("typeId", typeId);
         @SuppressWarnings("unchecked")
		 List<ReqUserRefEntity> list = query.list();
         if(list.size()>0)
		     return  list.get(0);
         else
        	 return new ReqUserRefEntity();
	}
}
